/**
 * 
 */
package com.metagurukul.metaspace.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * @author bhagyesh
 * 
 */
public class LoginForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String userName;
	private String password;
	/**
	 * 
	 */
	public LoginForm() {
		super();
	}
	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		if (userName == null || userName.length()<1 || userName.equals("username")) {
			errors.add("userName", new ActionMessage("error.userName.required"));
		}
		if (password == null || password.length()<1 || password.equals("password")) {
			errors.add("password", new ActionMessage("error.password.required") );
		}
		return errors;
	}

	public void reset(ActionMapping mapping, HttpServletRequest request) {
		userName = null;
		password = null;
	}
}
